package cn.wiseda.finance.utils;

public class MathUtil {
	private static final double EARTH_RADIU = 6378.137;
	
	public static double DistanceOfTwoPoints(double x1,double y1, double x2, double y2){
		double radx1 = y1*Math.PI/180.0;
		double radx2 = y2*Math.PI/180.0;
		double x =  radx1-radx2;
		double y = (x1-x2)*Math.PI/180.0;
		double dis = 2*Math.asin(Math.sqrt(Math.pow(Math.sin(x/2), 2)+Math.cos(radx1)*Math.cos(radx2)*Math.pow(Math.sin(y/2), 2)))*EARTH_RADIU;
		dis = Math.round(dis*10000)/10000;
		return dis;
	}

}
